import axioss from './request.js'

// 封装方法：得到文章详情
export function apiGetDetail (artid) {
  return axioss({
    url: `/app/v1_0/articles/${artid}`,
    needToken: true
  })
}

// 封装方法 获取关注用户
export function apiFollowings (autid) {
  return axioss({
    url: '/app/v1_0/user/followings',
    method: 'POST',
    needToken: true,
    data: {
      target: autid
    }
  })
}

// 封装方法 取消用户
export function apiCancel (autid) {
  return axioss({
    url: `/app/v1_0/user/followings/${autid}`,
    method: 'DELETE',
    needToken: true
  })
}

// 封装方法 对文章点赞
export function apiLikings (like) {
  return axioss({
    url: '/app/v1_0/article/likings',
    method: 'post',
    needToken: true,
    data: {
      target: like
    }
  })
}

// 封装方法 取消点赞
export function apiQux (chid) {
  return axioss({
    url: `/app/v1_0/article/likings/${chid}`,
    method: 'DELETE',
    needToken: true
  })
}

// 封装方法 对文章不喜欢
export function apiDiislikes (like) {
  return axioss({
    url: '/app/v1_0/article/dislikes',
    method: 'post',
    needToken: true,
    data: {
      target: like
    }
  })
}

// 封装方法 取消对文章的不喜欢
export function apiOrdinary (artid) {
  return axioss({
    url: `/app/v1_0/article/dislikes/${artid}`,
    method: 'DELETE',
    needToken: true
  })
}

// 封装方法 获取评论
export function apiComment ({ artid, offset, limit }) {
  return axioss({
    url: '/app/v1_0/comments',
    method: 'GET',
    needToken: false,
    params: {
      type: 'a',
      source: artid,
      offset: offset,
      limit: limit
    }
  })
}

// 封装方法 添加评论
export function apiTianj ({ artid, content }) {
  return axioss({
    url: '/app/v1_0/comments',
    method: 'post',
    needToken: true,
    data: {
      target: artid,
      content: content
    }
  })
}

// 封装方法 获取评论回复
export function apiReply ({ commid, offset, limit }) {
  return axioss({
    url: '/app/v1_0/comments',
    method: 'GET',
    needToken: false,
    params: {
      type: 'c',
      source: commid,
      offset: offset,
      limit: limit
    }
  })
}

// 添加评论的回复
export function apiReplyy ({ commid, content, artid }) {
  return axioss({
    url: '/app/v1_0/comments',
    method: 'POST',
    data: {
      target: commid,
      content: content,
      art_id: artid
    },
    needToken: true
  })
}


// 获取用户收藏列表(my 收藏)
export function apiCollecti ({ page, perpage }) {
  return axioss({
    url: '/app/v1_0/article/collections',
    method: 'GET',
    params: {
      page:page,
      per_page:perpage
    },
    needToken: true
  })
}
